/* Include these
   #include <time.h>
*/

#define T4_DAT_INIT { 0 }
#define T4_BRK_INIT { 0 }

typedef struct T4_in {
	double secs;
	time_t time;
} T4_in;

typedef struct T4_out {
	size_t chunk;
	float secs;
	int pipe;
} T4_out;

typedef struct T4_dat {
	/* unsigned int instead of size_t since data should be small. */
        unsigned int len;
	unsigned int max;
        char *str;
} T4_dat;

typedef struct T4_brk {
	int done;
        int amt;
} T4_brk;

enum t4_in_val { T4_IN_ERR, T4_IN_NONE, T4_IN_WAIT, T4_IN_STUFF };

int
t4_term_set(void);

void
t4_in_init(T4_in *in, float secs);

int
t4_in_status(void);

int
t4_in_empty(void);

enum t4_in_val
t4_in(T4_in *in, T4_dat *dat);

int
t4_out_init(T4_out *out, const char *path, double secs, size_t chunk);

int
t4_out_dispose(T4_out *out);

int
t4_out(T4_out *out, T4_dat *dat, T4_brk *brk);

int
t4_dat_init(T4_dat *dat, const char *str);

void
t4_dat_dispose(T4_dat *dat);

int
t4_dat_set(T4_dat *dat, const char *str);
